home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 1 / CU Amiga Magazine CD-ROM Special Edition (1995)(EMAP Images)(GB)[Issue 1995-11].iso / Aminet / comm / tcp / AmiTCPsdk_40.lha / AmiTCP-4.0 / netinclude / rpc / auth.h < prev    next >
C/C++ Source or Header  |  1994-10-03  |  4KB  |  147 lines

  1. #ifndef RPC_AUTH_H
  2. #define RPC_AUTH_H
  3. /*
  4.  * $Id: auth.h,v 4.1 1994/09/26 08:09:11 jraja Exp jraja $
  5.  *
  6.  * Authentication interface.
  7.  *
  8.  * Copyright © 1994 AmiTCP/IP Group,
  9.  *                  Network Solutions Development Inc.
  10.  *                  All rights reserved.
  11.  *
  12.  */
  13. /* @(#)auth.h    2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
  14.  
  15. /*
  16.  * Copyright (C) 1984, Sun Microsystems, Inc.
  17.  *
  18.  * The data structures are completely opaque to the client.  The client
  19.  * is required to pass a AUTH * to routines that create rpc
  20.  * "sessions".
  21.  */
  22.  
  23.  
  24. #define MAX_AUTH_BYTES    400
  25. #define MAXNETNAMELEN    255    /* maximum length of network user's name */
  26.  
  27. /*
  28.  * Status returned from authentication check
  29.  */
  30. enum auth_stat {
  31.     AUTH_OK=0,
  32.     /*
  33.      * failed at remote end
  34.      */
  35.     AUTH_BADCRED=1,            /* bogus credentials (seal broken) */
  36.     AUTH_REJECTEDCRED=2,        /* client should begin new session */
  37.     AUTH_BADVERF=3,            /* bogus verifier (seal broken) */
  38.     AUTH_REJECTEDVERF=4,        /* verifier expired or was replayed */
  39.     AUTH_TOOWEAK=5,            /* rejected due to security reasons */
  40.     /*
  41.      * failed locally
  42.     */
  43.     AUTH_INVALIDRESP=6,        /* bogus response verifier */
  44.     AUTH_FAILED=7            /* some unknown reason */
  45. };
  46.  
  47. #if (_M68000 || mc68000 || sparc || vax || i386 || tahoe || hp300)
  48. typedef u_long u_int32;    /* 32-bit unsigned integers */
  49. #endif
  50.  
  51. union des_block {
  52.     struct {
  53.         u_int32 high;
  54.         u_int32 low;
  55.     } key;
  56.     char c[8];
  57. };
  58. typedef union des_block des_block;
  59. extern bool_t XDRFUN xdr_des_block(XDR * xdrs, des_block * blkp);
  60.  
  61. /*
  62.  * Authentication info.  Opaque to client.
  63.  */
  64. struct opaque_auth {
  65.     enum_t    oa_flavor;        /* flavor of auth */
  66.     caddr_t    oa_base;        /* address of more auth stuff */
  67.     u_int    oa_length;        /* not to exceed MAX_AUTH_BYTES */
  68. };
  69. extern bool_t XDRFUN xdr_opaque_auth(XDR * xdrs, struct opaque_auth * ap);
  70.  
  71.  
  72. /*
  73.  * Auth handle, interface to client side authenticators.
  74.  */
  75. typedef struct AUTH {
  76.     struct    opaque_auth    ah_cred;
  77.     struct    opaque_auth    ah_verf;
  78.     union    des_block    ah_key;
  79.     struct auth_ops {
  80.         void    (*ah_nextverf)(struct AUTH *);
  81.         int    (*ah_marshal)(struct AUTH *, XDR *);    /* nextverf & serialize */
  82.         int    (*ah_validate)(struct AUTH *, struct opaque_auth *);    /* validate varifier */
  83.         int    (*ah_refresh)(struct AUTH *); /* refresh credentials */
  84.         void    (*ah_destroy)(struct AUTH *); /* destroy this structure */
  85.     } *ah_ops;
  86.     caddr_t ah_private;
  87. } AUTH;
  88.  
  89.  
  90. /*
  91.  * Authentication ops.
  92.  * The ops and the auth handle provide the interface to the authenticators.
  93.  *
  94.  * AUTH    *auth;
  95.  * XDR    *xdrs;
  96.  * struct opaque_auth verf;
  97.  */
  98. #define AUTH_NEXTVERF(auth)        \
  99.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  100. #define auth_nextverf(auth)        \
  101.         ((*((auth)->ah_ops->ah_nextverf))(auth))
  102.  
  103. #define AUTH_MARSHALL(auth, xdrs)    \
  104.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  105. #define auth_marshall(auth, xdrs)    \
  106.         ((*((auth)->ah_ops->ah_marshal))(auth, xdrs))
  107.  
  108. #define AUTH_VALIDATE(auth, verfp)    \
  109.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  110. #define auth_validate(auth, verfp)    \
  111.         ((*((auth)->ah_ops->ah_validate))((auth), verfp))
  112.  
  113. #define AUTH_REFRESH(auth)        \
  114.         ((*((auth)->ah_ops->ah_refresh))(auth))
  115. #define auth_refresh(auth)        \
  116.         ((*((auth)->ah_ops->ah_refresh))(auth))
  117.  
  118. #define AUTH_DESTROY(auth)        \
  119.         ((*((auth)->ah_ops->ah_destroy))(auth))
  120. #define auth_destroy(auth)        \
  121.         ((*((auth)->ah_ops->ah_destroy))(auth))
  122.  
  123.  
  124. extern struct opaque_auth _null_auth;
  125.  
  126.  
  127. /*
  128.  * These are the various implementations of client side authenticators.
  129.  */
  130.  
  131. /*
  132.  * Unix style authentication
  133.  */
  134. extern AUTH *authunix_create(char * machname, uid_t uid, gid_t gid,
  135.                  int len, gid_t * aup_gids);
  136. extern AUTH *authunix_create_default(void);
  137. extern AUTH *authnone_create(void);
  138. extern AUTH *authdes_create();
  139.  
  140. #define AUTH_NONE    0        /* no authentication */
  141. #define    AUTH_NULL    0        /* backward compatibility */
  142. #define    AUTH_UNIX    1        /* unix style (uid, gids) */
  143. #define    AUTH_SHORT    2        /* short hand unix style */
  144. #define AUTH_DES    3        /* des style (encrypted timestamps) */
  145.  
  146. #endif /* !RPC_AUTH_H */
  147.